package com.qf.leadnewsjob.conf;

import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class XXLJobConfig {

    @Value("${xxl.job.admin.address}")
    private String adminAddress;
    @Value("${xxl.job.executor.appname}")
    private String appname;
    @Value("${xxl.job.executor.ip}")
    private String ip;
    @Value("${xxl.job.executor.port}")
    private Integer port;

    @Bean
    public XxlJobSpringExecutor xxlJobExecutor() {
        XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();

        xxlJobSpringExecutor.setAdminAddresses(adminAddress);
        xxlJobSpringExecutor.setAppname(appname);

        //写执行器项目部署的机器ip
        xxlJobSpringExecutor.setIp(ip);
        //执行器服务的端口，同一台机器上部署多个执行器服务，要保证端口唯一性
        xxlJobSpringExecutor.setPort(port);


        return xxlJobSpringExecutor;
    }
}
